//
//  QCManualCheckCell.swift
//  爱汽车
//
//  Created by tucici on 2024/3/20.
//

import UIKit

class QCManualCheckCell: UICollectionViewCell {
    @IBOutlet var title: UILabel!
    @IBOutlet var backBtn: UIButton!
    @IBOutlet var startBtn: UIButton!
    @IBOutlet var des: UILabel!
    private var setupView:QCSetupView!
    var block:((_ title:String)->Void)?
    override func awakeFromNib() {
        super.awakeFromNib()
        initUI()
    }
    func initUI(){
        setupView = QCSetupView.loadFromXIB() as? QCSetupView
        setupView.style = .check(0)
        addSubview(setupView)
        setupView.snp.remakeConstraints { make in
            make.left.right.equalToSuperview().inset(0)
            make.bottom.equalTo(des.snp.top).offset(-20)
            make.top.equalTo(title.snp.bottom).offset(10)
            make.centerY.equalToSuperview().offset(-20)
            make.height.equalTo(kUIScreenHeight > 667 ? 436 : 386)
        }
    }
    var model = QCCheckMode.manual("", [UInt8](),""){
        didSet{
            if case let .manual( text, bytes, subtitle) = model{
                title.text = text
                des.text = LS(subtitle)
                guard bytes.count >= 8 else{return}
                setupView.bytes = bytes
            }
        }
    }
   
    @IBAction func actionForBtn(_ sender: UIButton) {
        block?(sender.currentTitle ?? "")
    }
}
